package com.d0318;

import java.util.Date;

public class JoinTester implements Runnable {
    private String name;
    private int time1;

    public JoinTester(String name,int x){
        this.name = name;
        this.time1 = time1;
    }
    @Override
    public void run() {
        System.out.println(name +" 线程开始于 "+new Date());
        try {
            Thread.sleep(time1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name +" 线程结束于 "+new Date());

    }

    public static void main(String[] args) {
        Thread thread1 = new Thread(new JoinTester("123",3000));
        Thread thread2 = new Thread(new JoinTester("456",4000));
        thread1.start();
        thread2.start();

        try {
            thread1.join();
            thread2.join();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("主线程运行结束");

    }
}
